<?php
$this->Html->addCrumb('<i class="fa fa-home"></i> ' . Inflector::camelize($this->request->params ['prefix']), '/' . $this->request->params ['prefix'] . '/', array('escape' => false));
$this->Html->addCrumb(__('Users'), array('prefix' => $this->request->params['prefix'], 'controller' => $this->request->params['controller'], 'plugin' => $this->request->params['plugin'], 'action' => 'index'), array('escape' => false));
$this->Html->addCrumb(__('List'), NULL, array('escape' => false));

$this->Html->setAcoes('<i class="fa fa-plus"></i>' . __('New'), array('action' => 'add'), array('title' => __('new'), 'class' => 'btn btn-success', 'escapeTitle' => false));
$this->Html->setAcoes('<i class="fa fa-search"></i>' . __('List'), array('action' => 'index'), array('title' => __('List'), 'class' => 'btn btn-info', 'escapeTitle' => false));
$this->Html->setAcoes('<i class="fa fa-file-text-o"></i>' . __('Export'), array('action' => 'export'), array('title' => __('Export'), 'class' => 'btn btn-default', 'escapeTitle' => false));
?>

<div class="row divFormPesquisa">
    <?php
    echo $this->Form->create('User', array(
        'inputDefaults' => array(
            'div' => array('class' => 'form-group col-xs-12 col-md-3'),
            'label' => false,
            'wrapInput' => false,
            'class' => 'form-control col-xs-12'
        ),
        'class' => 'form-group busca_form_intranet',
        'url' => array_merge(array('action' => 'admin_index'), $this->request->params['named']),
        'novalidate' => true,
        'formnovalidate' => false,
        'role' => 'form',
        'type' => 'post'
    ));
    echo $this->Form->input('User.name', array('placeholder' => __('Name'), 'div' => array('class' => 'col-xs-12 col-md-3')));
    echo $this->Form->input('User.username', array('placeholder' => __('Username'), 'div' => array('class' => 'col-xs-12 col-md-3')));
    echo $this->Form->status('User.active', array('empty' => __('Todas Situações'), 'label' => false, 'div' => array('class' => 'col-xs-12 col-md-3')));
    echo $this->Form->limit('User.limit', array('div' => array('class' => 'col-xs-12 col-md-3')));
    echo $this->Form->end();
    ?> 
</div>

<?php if (count($users) > 0) { ?>
    <div class="table-responsive">
        <table class="table table-bordered table-hover table-condensed">
            <thead>
                <tr>
                    <th><?php echo $this->Paginator->sort('role', __('Role')); ?></th>
                    <th><?php echo $this->Paginator->sort('name', __('Name')); ?></th>
                    <th><?php echo $this->Paginator->sort('username', __('Username')); ?></th>
                    <th><?php echo $this->Paginator->sort('active', __('Active')); ?></th>
                    <th><?php echo $this->Paginator->sort('created', __('Created')); ?></th>
                    <th><?php echo $this->Paginator->sort('modified', __('Modified')); ?></th>
                    <th class="actions"><?php echo __('Actions'); ?></th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($users as $user) { ?>
                    <tr>
                        <td><?php echo h($user['User']['role']); ?></td>
                        <td><?php echo h($user['User']['name']); ?></td>
                        <td><?php echo h($user['User']['username']); ?></td>
                        <td><?php echo $this->Html->status($user['User']['active']); ?></td>
                        <td><?php echo $this->Formatacao->dataHora($user['User']['created']); ?></td>
                        <td><?php echo $this->Formatacao->dataHora($user['User']['modified']); ?></td>
                        <td class="actions">
                            <?php echo $this->Html->link('', array('action' => 'view', $user['User']['id']), array('icon' => 'fa fa-file-text-o', 'class' => 'btn btn-info btn-xs')); ?>
                            <?php echo $this->Html->link('', array('action' => 'edit', $user['User']['id']), array('icon' => 'fa fa-pencil', 'class' => 'btn btn-warning btn-xs')); ?>
                            <?php echo $this->Html->link('', array('action' => 'password', $user['User']['id']), array('label' => __('Change Password'), 'icon' => 'fa fa-pencil', 'class' => 'btn btn-warning btn-xs')); ?>
                        </td>
                    </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>
    <?php echo $this->Paginator->pagination(); ?>
    <?php
} else {
    echo $this->element('sem_registro');
}
?>